package zero.tech.wsnet.common;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import zero.tech.core.find.DynamicFind;
import zero.tech.wsnet.data.IREQ;

public class ReqProcessManager extends DynamicFind {
	private final Map<String, Class<?>> processClazzMap = new ConcurrentHashMap<String, Class<?>>();

	private ReqProcessManager() {
	}

	private static ReqProcessManager processManager = new ReqProcessManager();

	public static ReqProcessManager getManager() {
		return processManager;
	}

	@Override
	public boolean verification(Class<?> clazz) {
		return annotationOn(clazz, IREQ.class);
	}

	@Override
	public void findClass(Class<?> clz) throws Exception {
		IREQ iProcess = clz.getAnnotation(IREQ.class);
		processClazzMap.put(iProcess.code(), clz);
	}

	public Class<?> getProcess(String code) {
		return processClazzMap.get(code);
	}

	@Override
	public void afterFind() {
	}

	@Override
	public void beforeFind() {
	}
}
